package com.cloud.school.bus.teacherhelper.modules.login.baseactivity;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import android.content.Intent;
import android.os.Bundle;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

import com.android.support.jhf.edittextclear.EditTextClearView;
import com.android.support.jhf.handlerui.HandlerPostUI;
import com.android.support.jhf.handlerui.HandlerToastUI;
import com.android.support.jhf.network.NetworkClient;
import com.android.support.jhf.network.loopj.android.http.ResponseHandlerInterface;
import com.android.support.jhf.onClick.OnClickNetworkStatusListener;
import com.android.support.jhf.utils.ValidateOperator;
import com.cloud.school.bus.teacherhelper.base.activity.BaseActivity;
import com.cloud.school.bus.teacherhelper.base.utils.AppUserId;
import com.cloud.school.bus.teacherhelper.base.utils.SaveUserOperate;
import com.cloud.school.bus.teacherhelper.base.view.TitleNavBarView;
import com.cloud.school.bus.teacherhelper.R;

/**
 * 登陆基类
 * 
 * @author lenovo
 * 
 */
public class BaseLoginActivity extends BaseActivity {

	protected EditTextClearView mUserNameEditTextClearView;
	protected EditTextClearView mPasswordEditTextClearView;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

	}

	@Override
	protected void init() {

		mUserNameEditTextClearView = (EditTextClearView) findViewById(R.id.userNameEditTextClearView);
//		String phoneNumberString = SaveUserOperate.getLoginPhone(mContext);
//		if (!phoneNumberString.equals("")) {
//			mPhoneEditTextClearView.getEditText().setText(phoneNumberString);
//		}
		mPasswordEditTextClearView = (EditTextClearView) findViewById(R.id.passwordEditTextClearView);


	}

	@Override
	protected void setListener() {
		
	}

	protected void setTitleNavBar(String titleString,
			final OnClickListener onClickListener) {
		final TitleNavBarView titleNavBarView = (TitleNavBarView) findViewById(R.id.titleNavBarView);
		titleNavBarView.setMessage(titleString);
		titleNavBarView.setLeftButtonOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if (null != onClickListener) {
					onClickListener.onClick(v);
				} else {
					finish();
				}
			}
		});
		titleNavBarView.setRightButtonVisibility(View.INVISIBLE);
	}

	protected boolean checkStartUse(StringBuilder errorStringBuilder) {
		errorStringBuilder.delete(0, errorStringBuilder.length());

		if (TextUtils.isEmpty(mUserNameEditTextClearView.getEditText().getText()
				.toString())) {
			errorStringBuilder.append(getString(R.string.enter_account_and_password));
			return false;
		} else if (TextUtils.isEmpty(mPasswordEditTextClearView.getEditText()
				.getText().toString())) {
			errorStringBuilder.append(getString(R.string.enter_account_and_password));
			return false;
		} 

		return true;
	}

}
